Account: User Information
Web-SDK provides information about users who are currently accessing EdgerOS device.
Functions
edger.user()
- Returns: {Promise} Promise object.
Get current user information. If successful, the data
object contains the following fields:
acoid
{String} ACOINFO id string.nickname
{String} Current user nickname.profile
{String} User avatar URL.
Example
edger.user().then(data => {
const { acoid, nickname, profile } = data;
console.log('User:', acoid, nickname, profile);
}).catch(error => {
console.error(error);
});
async / await
async function user() {
try {
return await edger.user();
} catch (error) {
console.error(error);
}
}
Events
The unified event listener provided by Web-SDK:
const listener = (payload) => {
// Event handling...
}
// add listener
edger.addEventListener('some-event', listener);
// or
// onAction() is an alias of addEventListener().
edger.onAction('some-event', listener);
// remove listener
edger.removeEventListener('some-event', listener);
// remove all listeners
edger.removeAllListeners();
login
There is a new user login.
Example
const listener = (payload) => {
const { acoid, nickname, profile } = payload;
console.log('User:', acoid, nickname, profile);
}
edger.addEventListener('login', listener);
logout
The current user has been logged out.
Example
const listener = () => {
// Can clear current user information.
}
edger.addEventListener('logout', listener);